package com.c.config;

import com.c.exceptions.MyException;
import com.c.pojo.enums.ResultEnum;
import com.c.pojo.vo.ResultVo;
import com.c.util.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author bysun
 */
@ControllerAdvice
public class ExceptionHandle {

    @ResponseBody
    @ExceptionHandler(value = MyException.class)
    public ResultVo myExceptionHandler(MyException ex) {
        return ResultUtil.error(ex.getResultEnum());
    }
}
